@include('public.head')
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="">
        <div>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>
                        产品添加
                    </h5>
                </div>
                <div class="ibox-content">
                    <form method="post" action="" class="form-horizontal m-t">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">url</label>
                            <div class="col-sm-6">
                                <input type="text"  name="url" class="form-control file" style="padding:4px 12px" value="">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">背景图片</label>
                            <div class="col-sm-6">
                               <input type="file" name="image" class="form-control file" style="padding:4px 12px">

                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序</label>
                            <div class="col-sm-6">
                                <input type="num" min="0"  name="order" class="form-control file" style="padding:4px 12px" value="">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                      

                        <input type="hidden" name="id" value="">
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                               <button class="btn btn-primary">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    $(".m-t").submit(function(e){
        var form = new FormData();
        var url = $("input[name='url']").val();
        var id = $("input[name='id']").val();
        var image = $('input[name="image"]')[0].files[0];
        var order = $("input[name='order']").val();
        
        form.append("url", url);
        form.append("order", order);
        form.append("image", image);
        form.append("id", id);


        $.ajax({
            url:"/add_banner_do",    //请求的url地址
            dataType:"json",   //返回格式为json
            data:form,    //参数值
            processData: false,
            contentType: false,   
            type:"POST",   //请求方式
            success:function(req){
                //请求成功时处理
                if(req.status == 0){
                    layer.msg(req.message);
                    return false;
                }
                   
                layer.msg('操作成功！');
                // setTimeout(function(){
                //      window.location.href = "/banner";
                // },1000);
            }
        });
        return false;
    });
</script>
</body>
</html>